# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Maintainer: Jan de Groot <jgc@archlinux.org>

pkgname=libcaca
pkgver=0.99.beta19
pkgrel=5
pkgdesc="Color AsCii Art library"
url="http://caca.zoy.org/wiki/libcaca"
arch=(x86_64)
license=(custom:WTFPL)
depends=(imlib2 ncurses)
makedepends=(git)
_commit=caae67dce5d72ceceac79468bed47b58ea8e4a29  # tags/v0.99.beta19
source=("git+https://github.com/cacalabs/libcaca#commit=$_commit"
        57.patch)
sha256sums=('SKIP'
            'ece7dc2cf7e0252a88ff943ec0851c19aeeab5d20b26396984810524347ea38a')

pkgver() {
  cd libcaca
  git describe --tags | sed 's/^v//;s/-/+/g'
}

prepare() {
  cd libcaca

  # CVE-2021-3410
  # https://bugs.archlinux.org/task/70053
  git cherry-pick -n 46b4ea7c e4968ba6

  # CVE-2021-30498 CVE-2021-30499
  # https://bugs.archlinux.org/task/70520
  git apply -3 ../57.patch

  # Fix up version
  sed -i '/^AC_INIT/s/beta19pre/beta19/;/^LT_MICRO=/s/18/19/' configure.ac

  autoreconf -fvi
}

build() {
  cd libcaca
  ./configure \
    --prefix=/usr \
    --libexecdir=/usr/lib \
    --mandir=/usr/share/man \
    --enable-shared \
    --disable-csharp \
    --disable-cxx \
    --disable-doc \
    --disable-gl \
    --disable-python \
    --disable-slang \
    --disable-static
  make
}

package() {
  cd libcaca
  make DESTDIR="$pkgdir" install
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 COPYING
}

# vim:set sw=2 et:
